<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  let arr = [11, 11, 33, 33, 44, 55, 44, 55];

  //indexOf() 为-1 就是检测数组中没有这个元素；
  function quchong(arr) {
    var newarr = [],
        length = arr.length;
    for (let i = 0; i < length; i++) {
      if (newarr.indexOf(arr[i]) == -1) {
        newarr.push(arr[i])
      }
    }
    return newarr;
  }

  //console.log(quchong(arr));

  function quchong2(arr) {
    var tem = {},
        newarr = [],
        length = arr.length;
    for (let i = 0; i < length; i++) {
      if (!tem[arr[i]]) {
        tem[arr[i]] = 'abc';
        newarr.push(arr[i])
      }
    }
    return newarr
  }

  console.log(quchong2(arr));
</script>
</body>
</html>